Existing density and viscosity sensors measure density and viscosity of a subterranean formation fluid downhole. Such sensors operate based on the principle of a mechanically vibrating and resonating element interacting with the formation fluid flowing within a flowline of the downhole tool. The sensors measure the mechanical resonance of the resonating element vibrating in the fluid flowing in the flowline, outputting voltage-versus-time data that conforms to a simple damped harmonic model. The data is processed to determine the resonance frequency and quality factor, from which the density and viscosity of the fluid may be determined.